//
//  LcbImage.m
//  Lcb
//
//  Created by lcb on 16/6/12.
//  Copyright © 2016年 lcb. All rights reserved.
//

#import "LcbImage.h"
#import "SDWebImageManager.h"

@implementation LcbImage
LcbSingletonM(LcbImage)
+ (UIImage *)imageFromDiskCacheForUrlStr:(NSString *)urlString {
    
    NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:[NSURL URLWithString:urlString]];
    return [[SDWebImageManager sharedManager].imageCache imageFromDiskCacheForKey:key];
}

+ (NSUInteger)getCacheSize {
    
    return [[SDImageCache sharedImageCache] getSize]/1024/1024;
}

+ (void)removeImageForKey:(NSString*)key
{
    if (key && [key isKindOfClass:[NSString class]]&&key.length>0) {
        [[SDImageCache sharedImageCache] removeImageForKey:key];
    }
}

+ (void)storeImage:(UIImage*)image forKey:(NSString*)key
{
    if (image==nil || ![image isKindOfClass:[UIImage class]]) {
        return;
    }
    if (key==nil || ![key isKindOfClass:[NSString class]]|| key.length==0) {
        return;
    }
    [[SDImageCache sharedImageCache] storeImage:image forKey:key];
}
+ (void)clearMemory
{
    [[SDImageCache sharedImageCache] clearMemory];
}
+ (void)clearDisk
{
    [[SDImageCache sharedImageCache] cleanDisk];
    [[SDImageCache sharedImageCache] clearDisk];
}

@end
